create database weibo
go
create table users(
    userID bigint auto_increment not null primary key,
    account varchar(20) not null UNIQUE,
    userName nvarchar(24) not null,
    password varchar(30) not null,
    gender int not null,
    email varchar(75) null,
    introduce varchar(140) null,
    lastActivityDate datetime not null,
    createdOn datetime not null,
    fansCount bigint null,
    followedCount bigint null
)
go
create table follows (
    id bigint auto_increment not null primary key,
	userID bigint not null,
	followedID bigint not null,
	isFavorite bit not null,
	createdOn date not null,
	modifiedOn date not null
)
go
create table messages (
	messageID bigint auto_increment not null primary key,
	userID bigint not null,
	contentText nvarchar(140) not null,
	createdOn datetime not null,
	commentedCount int null,
	transferredCount int null
)
go
create table message_relations (
	messageID bigint not null,
	rootMessageID bigint not null,
	parentMessageID bigint not null,
	parentUserID bigint not null
)
go
create table option_logs(
	id bigint auto_increment not null primary key,
	userID bigint not null not null,
	operationType smallint not null,
	operationDataID bigint not null,
	createdOn datetime not null
)
go
create table comments(
	commentID bigint auto_increment not null primary key,
	messageID bigint not null,
	userID bigint not null,
	commentedContent nvarchar(140) not null,
	createdOn datetime not null
)
go